﻿using Abp.AspNetCore.Mvc.ViewComponents;
using Abp.Domain.Uow;
using Microsoft.AspNetCore.Mvc;
using Mt.Site.Application.SEO;
using Mt.Site.Web.Models.Layout;

namespace Mt.Site.Web.Components
{
    public class BackEndSeoViewComponent : AbpViewComponent
    {
        private readonly ISeoAppService _seoAppService;

        public BackEndSeoViewComponent(ISeoAppService seoAppService)
        {
            _seoAppService = seoAppService;

            LocalizationSourceName = MtSiteConsts.LocalizationSourceName;
        }


        public IViewComponentResult Invoke()
        {
            var dto = _seoAppService.GetBackEndSeo();

            var seoModel = ObjectMapper.Map<SeoModel>(dto);

            return View("~/Areas/B/Views/Shared/_Seo.cshtml", seoModel);
        }
    }
}